package panel.sinaWeiCo
{
	import assists.TextFieldUtils;
	
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	
	public class ScreenLockPanel extends Sprite
	{
		private var _stage:Stage;
		private var _showTxt:TextField;
		public function ScreenLockPanel(stage:Stage)
		{
			_stage = stage;
			init();
		}
		
		private function init():void
		{
			
			_showTxt = new TextField();
			_showTxt.autoSize = "left";
			_showTxt.text = "";
			_showTxt.mouseEnabled = false;
			_showTxt.y = _stage.stageHeight * 0.5 - _showTxt.height;
			this.addChild(_showTxt);
		}
		
		
		public function show(showTxt:String):void
		{
			TextFieldUtils.setHtmlText(_showTxt,showTxt);
			this.graphics.beginFill(0);
			this.graphics.drawRect(_showTxt.x,_showTxt.y,_showTxt.width,_showTxt.height);
			this.graphics.endFill();
			_showTxt.x = (_stage.stageWidth - _showTxt.width) * 0.5;
		}
		
		public function endShow(showTxt:String):void
		{
			TextFieldUtils.setHtmlText(_showTxt,showTxt);
			_showTxt.x = (_stage.stageWidth - _showTxt.width) * 0.5;
			this.graphics.beginFill(0);
			this.graphics.drawRect(_showTxt.x,_showTxt.y,_showTxt.width,_showTxt.height);
			this.graphics.endFill();
			TweenLite.to(this,3,{alpha:0,onComplete:close});
		}
		
		private function close():void
		{
			if(this.parent)
			{
				this.parent.removeChild(this);
			}
		}
		
	}
}